#include "operaterwidget.h"

OperaterWidget::OperaterWidget(QWidget *parent)
    : QWidget{parent}
{

    this->resize(1000,800);
    QListWidget *m_pListW =new QListWidget(this);
    m_pListW->addItem("好友");
    m_pListW->addItem("图书");

    //对象实例化
    m_pFriend=new Friend;
    m_pBook=new Book;

    //页面挂载
    m_pSW=new QStackedWidget;
    //堆栈窗口不指定的话，默认显示第一个
    m_pSW->addWidget(m_pFriend);
    m_pSW->addWidget(m_pBook);


    QHBoxLayout *pMain =new QHBoxLayout;
    pMain->addWidget(m_pListW);
    pMain->addWidget(m_pSW);

    setLayout(pMain);

    //左边 m_pListW 点击不同的列表时发出的信号, currentRowChanged 改变后，进行设置 setCurrentIndex
    connect(m_pListW,&QListWidget::currentRowChanged,m_pSW,&QStackedWidget::setCurrentIndex);

}

OperaterWidget &OperaterWidget::getInstance()
{
    //定义静态对象
    static OperaterWidget instance;
    return instance;
}
